---
title: 'Replication materials for:<br>"From gridlock to ratchet: Conditional cooperation on climate change"'
author: "Sam S. Rowan"
date: '2025-02-03'
bibliography: grateful-refs.bib
output: 
  html_document:
    standalone: true
    toc: true
    toc_float:
      collapsed: false
      smooth_scroll: true
---



# Getting started

To replicate the tables and figures in the main text and in the supplementary information make sure that you download the entire replication archive from the Dataverse and unzip it into one folder. 

# Folder structure

The replication archive contains the following folders:

+ `./code/`: Contains all the scripts necessary to replicate figures and tables in the paper and appendix. 
+ `./input/`: Contains raw data files that are used to make variables for analysis
+ `./output/`: Contains data files of variables that are used in the analysis
+ `./plots/`: Contains created figures; figures created by the scripts will be saved here
+ `./text/`: Contains the manuscript, where the appendix materials are in the same file

In addition, the archive folder contains the following files:

+ "_readme_ratchet.rmd" and "_readme_ratchet.html": This file and the markdown script to generate it
+ "grateful-refs.bib": A file containing bibliographic information for R packages


# Scripts

Scripts to perform analysis are all located in the `./code/` folder. 
Below I list which script is used to make a particular table or figure.
The scripts do not need to be executed in any particular order. 

+ "00_make_analysis_data.R" contains code to load and clean raw data to make the analysis dataset. The final output is saved as "data_for_models20230920.Rds" in the `./output/` folder. This script performs multiple imputation to fill missing covariate data and targets data in a country panel; and then to fill missing dyadic total and sectoral trade data in a directed dyadic panel. Since the latter step works with a relatively large matrix, the multiple imputation uses parallel processing, and as a result, executing this script again will not yield the exact same variables as in the analysis file. This script does not need to be executed to perform the analyses in scripts 1--8.  
+ Users should set their working directory to the top-level replication folder, since file paths are relative to that directory


# Figures and tables in text

Figure 1: Global temperature across treaties

+ Created in script: "07_figure1.R"
+ Object in that script: `temperature_plot`

Figure 2: UK linegraph and global ratchet scatterplot

+ Created in script: "03_summary_figures.R"
+ Object in that script: `gbr_ratchet`, `paris_v_glasgow`

Figure 3: Ratchet map

+ Created in script: "03_summary_figures.R"
+ Object in that script: `ratchet_map`

Table 1: Trade results

+ Created in script: "01_main_models.R" 
+ Object in that script: `table1_latex`

Table 2: IOs results

+ Created in script: "01_main_models.R" 
+ Object in that script: `table2_latex`

# Figures and tables in supplementary information

Table SI-1, Table SI-2: Full regression tables for T1 and T2

+ Created in script: "01_main_models.R" 
+ Object in that script: `table1_full`, `table2_full`

Table SI-3: Summary statistics

+ Created in script: "03_summary_figures.R"
+ Object in that script: `table_summary_statistics`

Table SI-4: Correlation matrix

+ Created in script: "03_summary_figures.R"
+ Object in that script: `table_correlations`

Table SI-5: Additional measures of climate targets

+ Created in script: "02_extensions.R"
+ Object in that script: `table_targets_measurement`

Table SI-6: Additional measures using climate laws

+ Created in script: "02_extensions.R"
+ Object in that script: `table_targets_laws`

Table SI-7, Figure SI-1: Normalized trade matrices

+ Created in script: "08_non_row_standardized.R"
+ Object in that script: Table SI-7 `table_normalized_trade`, Figure SI-1 `common_support_trade`, `yhat_trade`

Table SI-8, Figure SI-2: Non-row-standardized IO matrices

+ Created in script: "08_non_row_standardized.R"
+ Object in that script: Table SI-8 `table_nonrowstd_io`, Figure SI-2 `common_support_ios`, `yhat_ios`

Table SI-9: Additional specification with regional dummies

+ Created in script: "08_non_row_standardized.R"
+ Object in that script: `table_regions`

Table SI-10, Figure SI-3: Interacting trade and IO spatial weights

+ Created in script: "08_non_row_standardized.R"
+ Object in that script: Table SI-8 `table_trade_by_ios`, Figure SI-2 `common_support_trade_ios`, `yhat_trade_by_ios`

Table SI-11, Figure SI-4: Sensitivity analysis

+ Created in script: "04_ri_sensitivity.R"
+ Objects in that script: Table SI-11 `ovb_minimal_reporting(sensitivity_paris)`, Figure SI-4 `sensitivity_paris`

Figure SI-5: Randomization inference

+ Created in script: "04_ri_sensitivity.R"
+ Object in that script: `ri_plot`

Table SI-12: Timing of NDC2 submissions

+ Created in script: "02_extensions.R
+ Object in that script: `table_mlogit_timing`


# Codebook 

Climate targets:
 
+ Code to create these variables is in "00_make_analysis_data.R"
+ All measures are hand coded from the NDC submissions available at: *https://unfccc.int/NDCREG*
+ `paris_target_safe`: Climate mitigation target in a country's 2015 NDC for the Paris Agreement. Final measure calculated as the percentage difference for national 2010 greenhouse gas emissions levels. Positive values are emissions reductions. Notes: (1) Data for GHG emissions series from Climate Watch; (2) Averages any "unconditional" and "conditional" targets. 
+ `paris_target_impute`: As above, but imputes missing targets. 
+ `paris_target_primap`: As above, but targets calculated using PRIMAP's GHG emissions series. 
+ `glasgow_target_safe`: As above for the Paris target, but for a country's 2021 NDC for the Glasgow Climate Pact.
+ `glasgow_target_impute`:  As above, but imputes missing targets.
+ `glasgow_target_primap`:  As above, but targets calculated using PRIMAP's GHG emissions series. 

Spatial weights:

+ Code to create these variables is in "00_make_analysis_data.R"
+ `tradeflow_percentage`: Row-standardized spatial weight for the Paris climate target of trade-weighted peers. Bilateral trade data is from CEPII, averaged over 2015--2020. 
+ `tradeflow_safe_percentage`: As above, but doesn't use imputed partners targets to calculate spatial weight
+ `tradeflow_z_percentage`: As above, but standardizes targets within income groups 
+ `eite_percentage`: As above for `tradeflow_percentage`, but bilateral trade is restricted to energy-intensive, trade-exposed sectors only. Underlying data is from COMTRADE, with missing data multiply imputed
+ `green_percentage`: As above, but for trade in clean energy goods
+ `competition_tradeflow_percentage`: As above, but spatial connectivity matrix uses the cosine similarity of bilateral trade flows
+ `tradeflow_laws`: Spatial weight for the count of trade-weighted peers' climate laws. Data is from Grantham Institute
+ `tradeflow_laws_new`: As above, but counts only climate laws passed in 2015--2019.
+ `eite_laws`: As above, but only using EITE trade
+ `io_percentage`: Row-standardized spatial weight for the Paris climate target of peers weighted by joint IO memberships. IO data from Correlates of War Formal Intergovernmental Organizations dataset (to 2014), and Roger and Rowan's dataset of Informal International Organizations (to 2010).
+ "08_non_row_standardized.R" re-creates these variables in GDP-normalized (for trade) or non-row-standardized (for IOs) formats

Covariates:

+ `trade_openness` (as a share of GDP), `industry` (as a share of GDP), `renewables_share` (as a share of electricity production), `fossil_rents` (sum of coal, oil and gas rents), `gdp_capita`: All from World Development Indicators
+ `region`: From Varieties of Democracy project




# R version and packages

The following packages are required to run the R scripts. You can copy and paste the commands below in your R console to automatically install or update them. 

```{r, eval=FALSE}
install.packages("Amelia") 
install.packages("broom")
install.packages("countrycode")
install.packages("data.table")
install.packages("DescTools") 
install.packages("grateful") 
install.packages("knitr")
install.packages("lsa")
install.packages("lubridate")
install.packages("magrittr")
install.packages("marginaleffects")
install.packages("modelsummary")
install.packages("nnet") 
install.packages("readxl")
install.packages("sensemakr") 
install.packages("tidyverse")
install.packages("WDI")

```

These are the R software and package versions:

```{r, echo=FALSE, message=FALSE, warning=FALSE, eval = T}
# Toggle eval = T to print sessionInfo()
library(Amelia) 
library(broom)
library(countrycode)
library(data.table)
library(DescTools) 
library(grateful) 
library(knitr)
library(lsa)
library(lubridate)
library(magrittr)
library(marginaleffects)
library(modelsummary)
library(nnet) 
library(readxl)
library(sensemakr) 
library(tidyverse)
library(WDI)

sessionInfo()

```

```{r, echo=FALSE, message=FALSE, warning=FALSE, eval = T}
cite_packages(
  output = "paragraph", 
  out.dir = ".", 
  dependencies = F,
  out.format = "Rmd")
```

